package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.testng.annotations.Test;

import com.example.fw.GroupObject;
import com.example.fw.Groups;

public class GroupModificationTests extends TestBase {
	
//Random rnd = new Random();
	
	/*@DataProvider(name = "randomGroups")
	public Iterator<Object[]> generateRandomGroups() {
		List<Object[]> list = new ArrayList<Object[]>();
		for (int i = 0; i < 2; i++) {
			GroupObject group = new GroupObject()
			.setName("name34" + rnd.nextInt())
			.setHeader("Header" + rnd.nextInt())
			.setFooter("Footer" + rnd.nextInt());
			list.add(new Object[]{group});
		}
	return list.iterator();
	}
	*/
	
	//@Test(dataProvider = "randomGroups")
	//public void testFirstGroupCanBeModified(GroupObject validGroup){
	@Test
	public void testFirstGroupCanBeModified(){
		Groups oldGroups = app.getGroupHelper().getGroups();
		GroupObject oldGroup = oldGroups.getSomeGroup();
		GroupObject newGroup = new GroupObject(oldGroup);
		newGroup.setName("Name123");
		app.getGroupHelper().modifyGroup(oldGroup, newGroup);
		Groups newGroups = app.getHibernateHelper().getGroups();
		
		//app.getGroupHelper().modifyGroup(oldGroup, newGroup);
		//Groups newList = app.getGroupHelper().getGroups();
		
		assertThat(newGroups, equalTo(oldGroups.withModified(newGroup)));
	}
}
